package com.lp.business.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.iframework.commons.domain.enums.RecordStatus;
import org.iframework.commons.util.fast.V;
import org.iframework.support.spring.hibernate.dao.BaseHibernateDaoSupport;
import org.iframework.support.spring.hibernate.service.BaseServiceSupport;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.lp.business.model.Look;
import com.lp.business.service.LookService;

/**
 * 查看信息模型服务接口实现类<br>
 * 说明：支持方法查阅实现接口
 * 
 * @author lp
 * @email lp@qq.com
 * @date 2018-08-23 10:38:18
 */
@Service("lookService")
public class LookServiceImpl extends BaseServiceSupport<Look, String> implements LookService {
	@Resource(name = "lookDao")
	public void setBaseHibernateDaoSupport(@Qualifier("lookDaoImpl") BaseHibernateDaoSupport<Look, String> baseHibernateDaoSupport) {
		this.baseHibernateDaoSupport = baseHibernateDaoSupport;
	}

	@Override
	public Integer freeLookCount(String memberId, String reportId) {
		if(V.isEmpty(memberId)||V.isEmpty(reportId)) {
			return 0;
		}
		Look model = new Look();
		model.setStatus(RecordStatus.AVAILABLE);
		model.setMemberId(memberId);
		model.setReportId(reportId);
		model.setIsFree("1");
		List<Look> models = this.findByModel(model, null, null);
		return V.isNotEmpty(models)?models.size():0;
	}
}